FROM bitnami/minideb:buster
LABEL maintainer "Bitnami <containers@bitnami.com>"

ENV PATH="/opt/bitnami/python/bin:/opt/bitnami/postgresql/bin:/opt/bitnami/node/bin:/opt/bitnami/nami/bin:$PATH"

COPY prebuildfs /
# Install required system packages and dependencies
RUN install_packages ca-certificates curl dirmngr ghostscript gnupg imagemagick libbsd0 libbz2-1.0 libc6 libedit2 libffi6 libgcc1 libgcrypt20 libgmp10 libgnutls30 libgpg-error0 libhogweed4 libicu63 libidn2-0 libldap-2.4-2 liblzma5 libncursesw6 libnettle6 libp11-kit0 libpq5 libreadline7 libsasl2-2 libsqlite3-0 libssl1.1 libstdc++6 libtasn1-6 libtinfo6 libunistring2 libuuid1 libxml2 libxslt1.1 procps sudo unzip zlib1g
RUN /build/bitnami-user.sh && \
    /build/install-nami.sh
RUN bitnami-pkg install python-3.6.10-2 --checksum be882f108902cced8b37d06093ae90f4cfbd8575043d65e0ada58cb50650d48c
RUN bitnami-pkg install postgresql-client-11.7.0-0 --checksum 3cd9b46ecb3a60b398e6ed75318f5572619caa143f7d921a7151df3ce7b1727a
RUN bitnami-pkg install node-12.16.1-0 --checksum 36bab987be1cc792c7155e30545b004b76fc9a81796afec343a0a698935204b2
RUN bitnami-pkg unpack odoo-11.0.20200215-0 --checksum 1b6f4f30ecc40aeeb250b0d6836fd4045328f4ddb364039c3348dedec248b6d5
RUN apt-get update && apt-get upgrade -y && \
    rm -r /var/lib/apt/lists /var/cache/apt/archives
RUN /build/install-gosu.sh
RUN /build/install-tini.sh
#levin
# RUN  apt-get install -y --no-install-recommends \
RUN install_packages  \
python3-lxml \
python3-yaml \
python3-geoip2 \
python3-geoip \
python3-ldap \
xfonts-75dpi \
xfonts-base \
python-soappy \
unoconv ffmpeg ghostscript imagemagick \
#        && curl -o wkhtmltox.deb -sSL https://gitee.com/levin222/temp/raw/master/wkhtmltox_0.12.5-1.buster_amd64.deb\
        && curl -o wkhtmltox.deb -sSL https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb\
#        && echo '1602f0ef70a7047e930309b13557edb3 wkhtmltox.deb' | sha1sum -c - \
        && dpkg --force-depends -i wkhtmltox.deb\
        && apt-get -y install -f --no-install-recommends \
        && rm -rf /var/lib/apt/lists/* wkhtmltox.deb
#RUN apt install -y python3.6-dev  python3-lxml  python3-yaml && apt update -y
RUN install_packages  build-essential autoconf libtool pkg-config python-opengl python-pil python-pyrex  idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev libssl-dev
#python-pyside.qtopengl
## && easy_install greenlet && easy_install gevent
COPY . .
RUN pip3 install --upgrade setuptools && pip3 install --upgrade wheel && pip3 install num2words xlwt \
#   && pip3 install -r ./r.txt \
openupgradelib  requests  user_agents  lxml  phonenumbers  py-Asterisk  checksumdir  raven  acme_tiny  IPy  bokeh==0.12.7  asn1crypto==0.22.0  bcrypt==3.1.4  boto3==1.5.22  botocore==1.8.38  certifi==2017.7.27.1  cffi==1.10.0  chardet==3.0.4  cryptography  docutils==0.12  dropbox==8.7.0  gevent==1.2.2  greenlet==0.4.10  idna==2.5  jmespath==0.9.3  paramiko==2.4.1  pyasn1==0.4.2  pycparser==2.18  pynacl==1.2.1  pysftp==0.2.8  #requests==2.17.1  s3transfer==0.1.12  #urllib3==1.21.1  urllib3==1.22  xlsxwriter  xlrd  emoji  pygal  cairosvg  tinycss  cssselect  wechatpy  wdb  requests-mock  python-alipay-sdk  fdfgen  numpy  unicodecsv  xlutils  docxtpl  pdfkit  httplib2  ovh  bokeh==0.12.7  acme-tiny  IPy  pandas  gdata  genshi  oauthlib   pymemcache  httpagentparser  moviepy  Wand  unoconv  simplejson  serial  odfpy  PyPDF2  pycountry  suds-jurko==0.6  num2words  python-magic  requests \
  && pip3 install https://github.com/OneDrive/onedrive-sdk-python/archive/master.zip
#levin
RUN sed -i "s/load(yaml_string)/load(yaml_string, Loader=yaml.Loader)/g" /opt/bitnami/odoo/odoo/tools/yaml_import.py
RUN mv GeoLite2-City.tar.gz /tmp/GeoLite2-City.tar.gz \
    && mkdir -p /usr/share/GeoIP \
    && chown -R bitnami:bitnami /usr/share/GeoIP \
    && tar -xf /tmp/GeoLite2-City.tar.gz -C /tmp/ \
    && find /tmp/GeoLite2-City_* | grep "GeoLite2-City.mmdb" | xargs -I{} mv {} /usr/share/GeoIP/GeoLite2-City.mmdb
#    && pip3  install GeoIP
COPY rootfs /
ENV BITNAMI_APP_NAME="odoo" \
    BITNAMI_IMAGE_VERSION="11.0.20200215-debian-10-r9" \
    LD_LIBRARY_PATH="/opt/bitnami/odoo/venv/lib/python3.6/site-packages/reportlab/.libs:$LD_LIBRARY_PATH" \
    ODOO_EMAIL="user@example.com" \
    ODOO_PASSWORD="bitnami" \
    POSTGRESQL_HOST="postgresql" \
    POSTGRESQL_PASSWORD="" \
    POSTGRESQL_PORT_NUMBER="5432" \
    POSTGRESQL_USER="postgres" \
    SMTP_HOST="" \
    SMTP_PASSWORD="" \
    SMTP_PORT="" \
    SMTP_PROTOCOL="" \
    SMTP_USER=""

EXPOSE 8069 8071

ENTRYPOINT [ "/app-entrypoint.sh" ]
CMD [ "nami", "start", "--foreground", "odoo" ]
